<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改用户密码</title>
    <link rel="stylesheet" href="/js/bootstrap.min.css">
    <script src="/js/jquery-3.2.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {

            getParam();

            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null)
                    return unescape(r[2]);
                return null; //返回参数值
            };

            function getParam() {
                var userId = getUrlParam("userId");
                $("#adda").attr("href", "UserMenu.html?userId=" + userId);
                $("#ids").attr("value", userId);
            };

            $("#button").click(function () {
                var newUser = $("#addForm form")[0];
                var formaDate = new FormData(newUser);
                $.ajax({
                    url: "/applets/user/update",
                    type: "post",
                    data: formaDate,
                    contentType: false,
                    processData: false,
                    success: function (data) {
                        alert(data.msg);
                    }
                });
                return false;
            });

        });
    </script>
</head>
<body>
<div class="container" id="addForm">
    <h2 class="text-center">用户修改</h2>

    <!--导航-->
    <ul class="nav nav-tabs">
        <li class="nav-item">
            <a class="nav-link active" href="#" id="adda">返回用户菜单</a>
        </li>
    </ul>

    <form action="#" method="post">
        <div class="form-group">
            <label>ID</label>
            <input type="text" class="form-control" name="id" id="ids" readonly>
        </div>
        <div class="form-group">
            <label>密码</label>
            <input type="text" class="form-control" name="upass">
        </div>
        <div class="form-group">
            <input type="button" class="form-control" id="button" value="确认修改">
        </div>
    </form>

</div>
</body>
</html>